package single;

import java.util.ArrayList;
import java.util.List;

public abstract class CopyOfEvent {

	{
		System.out.println("heheheh");
	}
	static {
		System.out.println("static");
	}
	protected List list = new ArrayList();
	public abstract List process(String eventStr) throws Exception;
	
	protected static String transSeverity(String s) {
		String serv = "1";
		if (s.equals("URG")||s.equals("***")) {
			serv = "5";
		} else if (s.equals("SURG")||s.equals("**")) {
			serv = "4";
		} else if (s.equals("NURG") || s.equals("NON URGENT") ||s.equals("*")) {
			serv = "3";
		} else if (s.equals("Warning")) {
			serv = "2";
		} else if (s.equals("1")) {
			serv = "1";
		}
		return serv;
	}

	protected static String transType(String t) {
		String type = "1";
		if ("ON".equals(t)) {
			type = "1";
		} else if ("OFF".equals(t)) {
			type = "2";
		}
		return type;
	}

	protected static String strip(String s) {
		if (s != null) {
			StringBuffer sb = new StringBuffer();
			String[] ss = s.split("\n");
			for (int i = 0; i < ss.length; i++) {
				ss[i] = ss[i].replaceAll("\\s{3,}", "  ");//ÿ����>=3�Ŀո��滻Ϊ2���ո�
				sb.append(ss[i].trim());
				sb.append("   ");//����Ϊ3���ո�
			}
			s = sb.toString().trim();
			//s = s.replaceAll("\n", "   ");// ȥ����
			//s = s.replaceAll("\\s{3,}", "  ");// 3���ո����ϵ��滻Ϊ2���ո�
			//s = s.trim();
		}
		return s;
	}

	protected static String trimRight(String value) {
		String result = value;
		if (result == null)
			return result;
		char ch[] = result.toCharArray();
		int endIndex = -1;
		for (int i = ch.length - 1; i > -1; i--) {
			if (Character.isWhitespace(ch[i])) {
				endIndex = i;
			} else {
				break;
			}
		}
		if (endIndex != -1) {
			result = result.substring(0, endIndex);
		}
		return result;
	}
	
	//ȥ��ÿ�����Ŀո�
	protected static String trimLinesRight(String eventStr) {
		StringBuffer s = new StringBuffer();
		String[] lines = eventStr.split("\n");
		for (int i = 0; i < lines.length; i++) {
			s.append(trimRight(lines[i]));
			if (i != lines.length - 1) {
				s.append("\n");
			}
		}
		return s.toString();
	}

	protected static String appendSpace(int size) {
		StringBuffer s = new StringBuffer();
		for (int i = 0; i < size; i++) {
			s.append(" ");
		}
		return s.toString();
	}

}
